<!doctype html>
<%@ page language="java" import="java.util.*" contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html class="">
<head>
<meta charset="utf-8">
<base href="<%=basePath%>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="target-densitydpi=device-dpi, width=640, user-scalable=no">
<link href="assets/css/sstmobi/sstmobi.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="assets/js/jquery.js"></script>
<script type="text/javascript">
$(function () {
    var DEFAULT_WIDTH = 640, // 页面的默认宽度
        ua = navigator.userAgent.toLowerCase(), // 根据 user agent 的信息获取浏览器信息
        deviceWidth = window.screen.width, // 设备的宽度
        devicePixelRatio = window.devicePixelRatio || 1, // 物理像素和设备独立像素的比例，默认为1
        targetDensitydpi;

    // Android4.0以下手机不支持viewport的width，需要设置target-densitydpi
    //if (ua.indexOf("android") !== -1 && parseFloat(ua.slice(ua.indexOf("android")+8)) < 4) {
        targetDensitydpi = DEFAULT_WIDTH / deviceWidth * devicePixelRatio * 160;
        $('meta[name="viewport"]').attr('content', 'target-densitydpi=' + targetDensitydpi +
                ', width=640px, user-scalable=no');
    //}

    // TODO: 其他手机需要特殊处理的在下面
});
</script>
<script type="text/javascript" src="assets/js/zepto.min.js"></script>
<script type="text/javascript" src="http://g.alicdn.com/ilw/ding/0.7.3/scripts/dingtalk.js">
</script>
<script type="text/javascript" src="assets/js/logger.js">
</script>
<script type="text/javascript" >
/**
 * Created by linxinkai on 8/10/15.
 */

/**
 * _config comes from server-side template. see views/index.jade
 */
 var _config = ${config};
 function ssss(a,b,c){
	 	$.post("rest/dingding/visitorapp/setret", {
	 		c : c,
	 		visitorId : a,
	 		type : b
	 	}, function(json) {
	 		var success = json.success;
	 		if(success){
// 	 			alert("操作成功");
	 			history.go(0);
	 		} else {
	 			alert("操作失败");
	 			history.go(0);
	 		}
	 	},"json");
	}
dd.config({
			agentId : _config.agentid,
			corpId : _config.corpId,
			timeStamp : _config.timeStamp,
			nonceStr : _config.nonceStr,
			signature : _config.signature,
			jsApiList : [ 'runtime.info', 'biz.contact.choose',
					'device.notification.confirm', 'device.notification.alert',
					'device.notification.prompt', 'biz.ding.post',
					'biz.util.openLink' ]
		});

dd.ready(function() {
    dd.biz.navigation.setTitle({
        title: '访客记录',
        onSuccess: function(data) {
        },
        onFail: function(err) {
            log.e(JSON.stringify(err));
        }
    });
//	 alert('dd.ready rocks!');

	dd.runtime.info({
		onSuccess : function(info) {
			logger.e('runtime info: ' + JSON.stringify(info));
		},
		onFail : function(err) {
			logger.e('fail: ' + JSON.stringify(err));
		}
	});
	dd.ui.pullToRefresh.enable({
	    onSuccess: function() {
	    },
	    onFail: function() {
	    }
	})

	dd.biz.navigation.setMenu({
		backgroundColor : "#ADD8E6",
		items : [
			{
				id:"搜索",//字符串
			// "iconId":"file",//字符串，图标命名
			  text:"搜索"
			}
//			,
//			{
//				"id":"2",
//			"iconId":"photo",
//			  "text":"我们"
//			}
		],
		onSuccess: function(data) {
			alert(JSON.stringify(data));

		},
		onFail: function(err) {
			alert(JSON.stringify(err));
		}
	});


	dd.runtime.permission.requestAuthCode({
		corpId : _config.corpId,
		onSuccess : function(info) {
			$.ajax({
				url : 'userinfo?code=' + info.code + '&corpid='
						+ _config.corpId,
				type : 'GET',
				success : function(data, status, xhr) {
					var info = JSON.parse(data);
// 					document.getElementById("userName").innerHTML = info.name;
// 					document.getElementById("userId").innerHTML = info.userid;
					// 图片
//					if(info.avatar.length != 0){
//			            var img = document.getElementById("userImg");
//			            img.src = info.avatar;
//			                      img.height = '100';
//			                      img.width = '100';
//			          }

				},
				error : function(xhr, errorType, error) {
					logger.e("yinyien:" + _config.corpId);
					alert(errorType + ', ' + error);
				}
			});

		},
		onFail : function(err) {
			alert('fail: ' + JSON.stringify(err));
		}
	});
});

dd.error(function(err) {
	alert('dd error: ' + JSON.stringify(err));
});

</script>
<title>首页</title>
</head>
<body style="background:#f4f4f4;">


<div class="view">
<div class="scroll-wrap">

<div class="MainBody">

    <div class="IncBodyer">
        
		<div class="GenStuBox_det">
            <div class="GstuInfo">
            	<div class="GstuName">${visitor.name}
            		<c:if test="${visitor.approvalStatus eq '核准中' }">
            			<span class="result_1">${visitor.approvalStatus }</span>
            		</c:if>
            		<c:if test="${visitor.approvalStatus eq '核准' }">
            			<span class="result_3">${visitor.approvalStatus }</span>
            		</c:if>
            		<c:if test="${visitor.approvalStatus eq '拒访' }">
            			<span class="result_2">${visitor.approvalStatus }</span>
            		</c:if>
<%--             		<span class="result_1">${visitor.approvalStatus }</span> --%>
            	</div>
                <div class="GstuSubInfo">${visitor.time } ${visitor.info }</div>
            </div>
        </div>
        
        <div class="GenDet_Col mt15">
        	<div class="D_Col">
            	<div class="D_Img"><img src="assets/img/sstmobi/icon_1.png"></div>
                <div class="D_Cont">
                	<div class="D_Tit">电话</div>
                    <div class="D_Info">${visitor.phone }</div>
                </div>
            </div>
        </div>
        
        <div class="GenDet_Col mt15">
        	<div class="D_Col">
            	<div class="D_Img"><img src="assets/img/sstmobi/icon_2.png"></div>
                <div class="D_Cont">
                	<div class="D_Tit">访客对象</div>
                    <div class="D_Info">${visitor.other }</div>
                </div>
            </div>
            <div class="D_Col">
            	<div class="D_Img"><img src="assets/img/sstmobi/icon_3.png"></div>
                <div class="D_Cont">
                	<div class="D_Tit">访问事由</div>
                    <div class="D_Info">${visitor.info }</div>
                </div>
            </div>
        </div>
        
        <div class="GenDet_Col mt15">
        	<div class="D_Col">
            	<div class="D_Img"><img src="assets/img/sstmobi/icon_4.png"></div>
                <div class="D_Cont">
                	<div class="D_Tit">入校时间</div>
                    <div class="D_Info">${visitor.time }</div>
                </div>
            </div>
            <div class="D_Col">
            	<div class="D_Img"><img src="assets/img/sstmobi/icon_5.png"></div>
                <div class="D_Cont">
                	<div class="D_Tit">出校时间</div>
                    <div class="D_Info">${visitor.endTime }</div>
                </div>
            </div>
            <div class="D_Col">
            	<div class="D_Img"><img src="assets/img/sstmobi/icon_6.png"></div>
                <div class="D_Cont">
                	<div class="D_Tit">备注</div>
                    <div class="D_Info">${visitor.memo }</div>
                </div>
            </div>
        </div>
        
        <div class="GenBtnBox">
       		 <c:if test="${visitor.approvalStatus eq '核准中' }">
           		<button onclick="ssss(${visitor.id},0,'${c }')" class="Btn_stat_1">拒绝访问</button>
	            <button onclick="ssss(${visitor.id},1,'${c }')" class="Btn_stat_2">接受访问</button>
       		</c:if>
       		<c:if test="${visitor.approvalStatus eq '核准' }">
       			  <button onclick="#" class="Btn_stat_3">已经批准</button>
       		</c:if>
       		<c:if test="${visitor.approvalStatus eq '拒访' }">
       			  <button onclick="#" class="Btn_stat_3">已经拒访</button>
       		</c:if>
        </div>
        
        
         
	
    </div>

</div>


</div>
</div>



</body>
</html>
